package com.chennan.redis.domain.service.singleflight;

import java.util.concurrent.CountDownLatch;

/**
 * @author chennan
 * @createTime 2021年06月29日 11:16:00
 */
public class Call {

    private byte[] val;

    private CountDownLatch cdl;

    public byte[] getVal() {
        return val;
    }

    public Call setVal(byte[] val) {
        this.val = val;
        return this;
    }

    public void await() {
        try {
            this.cdl.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public void lock() {
        this.cdl = new CountDownLatch(1);
    }
    public void done() {
        this.cdl.countDown();
    }
}
